<script>
    // Additional JS functions here
    window.fbAsyncInit = function () {
        FB.init({
            appId: '449559341758052', // App ID
            channelUrl: '//127.0.0.1:8080/channel.html', // Channel File
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
        });

        // Additional init code here
        FB.getLoginStatus(function (response) {
            if (response.status === 'connected') {
                // connected
				window.prompt("Welcome!  Fetching your information....");
                testAPI();
            } else if (response.status === 'not_authorized') {
                // not_authorized
                window.prompt("Welcome!  Fetching your information....");
                login();
            } else {
                // not_logged_in
                window.prompt("Welcome!  Fetching your information....");
                login();
            }
        });
    };

    function testAPI() {
        window.prompt("Welcome!  Fetching your information....");
        console.log('Welcome!  Fetching your information.... ');
        FB.api('/me', function (response) {
            console.log('Good to see you, ' + response.name + '.');
        });
    }

    function login() {
        FB.login(function (response) {
            if (response.authResponse) {
                // connected
            } else {
                // cancelled
            }
        });
    }

    // Load the SDK Asynchronously
    (function (d) {
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) { return; }
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    } (document));
</script>